﻿using System;
using System.Windows.Input;
using Controllers;
using Interfaces;

namespace Views.Moduler
{
    /// <summary>
    /// Interaction logic for BrugerHistorik.xaml
    /// </summary>
    public partial class BrugerHistorik
    {
        #region Fields

        private readonly Controller _controller;
        private readonly IBruger _iBruger;

        #endregion

        #region Creation

        public BrugerHistorik(Controller controller, IBruger iBruger)
        {
            InitializeComponent();
            _controller = controller;
            _iBruger = iBruger;

            Title = _iBruger.Navn;
            LblBrugerHistorik.Content = String.Format("Historik for {0} ({1})", _iBruger.Navn, _iBruger.Initialer);
            LwBrugerHistorik.ItemsSource = null;
            LwBrugerHistorik.ItemsSource = _controller.HentHistorikUdlånMedBruger(iBruger);
        }

        #endregion

        #region Event handlers

        private void Window_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Escape)
                Close();
        }

        #endregion
    }
}
